<template>
  <el-row :gutter="20">
    <el-col :span="24">
      <el-form
        :model="ruleForm"
        :rules="rules"
        ref="ruleForm"
        label-width="100px"
        class="demo-ruleForm"
      >
        <el-form-item label="充值卡号" prop="code">
          <el-input v-model="ruleForm.code"></el-input>
           <div>充值卡购买请添加站长微信<b style="color:red">88657429</b></div>
        </el-form-item>
       
        <el-form-item>
          <el-button type="primary" @click="submitForm('ruleForm')"
            >充值</el-button
          >
          <el-button @click="resetForm('ruleForm')">取消</el-button>
        </el-form-item>
      </el-form>
    </el-col>
  </el-row>
</template>
<script>
import { fieldMap, publicFilter } from "@/utils/showMap";
import { setUser, getUser, removeUser } from "@/utils/auth";
import { MessageBox, Message } from "element-ui";
import store from "@/store";
import { recharge} from "@/api/service";
export default {
  data() {
    return {
      typeOption: fieldMap.user_type,
      ruleForm: {
        code: "",
      },
      rules: {
        code: [
          { required: true, message: "请输入充值卡号", trigger: "blur" },
        ]
      },
    };
  },
  mounted() { },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          recharge({ code: this.ruleForm.code }, "me").then((res) => {
            this.ruleForm.code="";
            Message({
              message: res.msg || "充值成功",
              type: "success",
              duration: 3 * 1000,
            });
          });
        } else {
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
  },
};
</script>
<style lang="less" scoped>
.demo-ruleForm {
  text-align: left;
}
</style>
